home *** CD-ROM | disk | FTP | other *** search
- assume cs:text
- text segment para public 'CODE'
-
- extrn vramoff:dword
- public fbread4
- fbread4 proc near
- push ebp
- push ebx
- push ecx
- push edx
- push esi
- push edi
- mov edi,28[esp] ; edi <-- save
- mov edx,36[esp] ; edx <-- y
- shl edx,9 ; y * 512
- mov eax,32[esp] ; eax <-- x
- sar eax,1
- add edx,eax
- add edx,vramoff ; edx <-- vram address
- mov ebp,40[esp] ; ebp <-- height
- mov ebx,44[esp] ; ebx <-- height
- mov eax,32[esp]
- test eax,1
- jne SHORT #10 ; x is odd
- #00:
- mov esi,edx ; esi <-- vram
- mov ecx,ebp ; ecx <-- width
- #01:
- mov al,fs:[esi]
- inc esi
- mov [edi],al
- inc edi
- dec ecx
- je SHORT #02
- shr al,4
- mov [edi],al
- inc edi
- loop #01
- #02:
- add edx,0200H
- dec ebx
- jne SHORT #00
- jmp #end
-
- #10:
- mov esi,edx
- mov ecx,ebp
- mov al,fs:[esi]
- inc esi
- jmp SHORT #12
- #11:
- mov al,fs:[esi]
- inc esi
- mov [edi],al
- inc edi
- dec ecx
- je SHORT #13
- #12:
- shr al,4
- mov [edi],al
- inc edi
- loop #11
- #13:
- add edx,0200H
- dec ebx
- jne SHORT #10
-
- #end:
- pop edi
- pop esi
- pop edx
- pop ecx
- pop ebx
- pop ebp
- ret
- fbread4 endp
-
- public fbwrite4
- fbwrite4 proc near
- push ebp
- push ebx
- push ecx
- push edx
- push esi
- push edi
- mov esi,28[esp] ; esi <-- buf
- mov edx,36[esp] ; edx <-- y
- shl edx,9 ; y * 512
- mov eax,32[esp] ; eax <-- x
- sar eax,1 ; x / 2
- add edx,eax
- add edx,vramoff ; edx <-- vram offset
- mov ebp,40[esp] ; ebp <-- width
- mov ebx,44[esp] ; ebx <-- height
- mov eax,32[esp]
- test eax,1
- jne SHORT #10 ; x is odd
-
- #00:
- mov edi,edx ; edi <-- vram
- mov ecx,ebp ; ecx <-- width
- shr ecx,1
- je #02
- #01:
- mov ax,[esi]
- add esi,2
- and al,0fH
- shl ah,4
- or al,ah
- mov fs:[edi],al
- inc edi
- loop #01
- #02:
- test ebp,1
- je #03
- mov al,[esi]
- and al,0fH
- inc esi
- mov ah,fs:[edi]
- and ah,0f0H
- or ah,al
- mov fs:[edi],ah
- inc edi
- #03:
- add edx,0200H
- add esi,48[esp]
- dec ebx
- jne SHORT #00
- jmp SHORT #end
-
- #10:
- mov edi,edx ; edi <-- vram
- mov ecx,ebp ; ecx <-- width
- mov al,[esi]
- inc esi
- shl al,4
- mov ah,fs:[edi]
- and ah,0fH
- or ah,al
- mov fs:[edi],ah
- inc edi
- dec ecx
- shr ecx,1
- je SHORT #12
- #11:
- mov ax,[esi]
- add esi,2
- and al,0fH
- shl ah,4
- or al,ah
- mov fs:[edi],al
- inc edi
- loop #11
- #12:
- test ebp,1
- jne #13
- mov al,[esi]
- and al,0fH
- inc esi
- mov ah,fs:[edi]
- and ah,0f0H
- or ah,al
- mov fs:[edi],ah
- inc edi
- #13:
- add edx,0200H
- add esi,48[esp]
- dec ebx
- jne SHORT #10
-
- #end:
- pop edi
- pop esi
- pop edx
- pop ecx
- pop ebx
- pop ebp
- ret
- fbwrite4 endp
-
- text ends
- end
-